package cn.trigram.concurrent;


import java.util.concurrent.TimeUnit;

public class ThreadUtil {

  /**
   * sleep等待, 单位为毫秒, 已捕捉并处理InterruptedException.
   */
  public static void sleep(long durationMillis) {

    try {
      Thread.sleep(durationMillis);
    } catch (InterruptedException e) {
      Thread.currentThread().interrupt();
    }
  }

  /**
   * sleep等待，已捕捉并处理InterruptedException.
   */
  public static void sleep(long duration, TimeUnit unit) {

    try {
      Thread.sleep(unit.toMillis(duration));
    } catch (InterruptedException e) {
      Thread.currentThread().interrupt();
    }
  }

}
